package edu.washington.cs.workflow.analysis.guistructure;

import org.uispec4j.Panel;
import org.uispec4j.UISpecTestCase;
import org.uispec4j.interception.MainClassAdapter;

public class MainWindowCreator extends UISpecTestCase {
	
	public static Panel getFreshMainWindow(Class<?> mainClass, String[] args) {
		MainWindowCreator creator = new MainWindowCreator(mainClass, args);
		creator.setUpEnv();
		return creator.getMainWindow();
	}
	
	private final Class<?> mainClass;
	private final String[] args;
	
	private MainWindowCreator(Class<?> mainClass, String[] args) {
		this.mainClass = mainClass;
		this.args = args;
	}
	
	private void setUpEnv() {
		setAdapter(new MainClassAdapter(this.mainClass, this.args));
		try {
	        super.setUp();
		} catch (Throwable e) {
			throw new Error(e);
		}
	}
}